package flextv.main.command {

import com.adobe.cairngorm.commands.ICommand;
import com.adobe.cairngorm.control.CairngormEvent;

import flextv.core.logic.CoreModel;
import flextv.core.logic.Logger;
import flextv.core.vo.Playlist;
import flextv.main.event.AddPlaylistEvent;
import flextv.main.logic.MainServices;

import mx.collections.ArrayCollection;
import mx.logging.ILogger;

public class AddPlaylistCommand implements ICommand {
	
	private static const LOG: ILogger = Logger.getLog(AddPlaylistCommand);
	
	public function AddPlaylistCommand() {
		
	}

	public function execute(_event: CairngormEvent): void {
		const event: AddPlaylistEvent = _event as AddPlaylistEvent;
		LOG.info("Executing [event=" + event + "].");
		
		
		const p: Playlist = new Playlist("default title", new ArrayCollection());
		
		MainServices.instance.persistenceService.insertPlaylist(p);
		CoreModel.instance.playlists.addItem(p);
	}
	
}
}